<%@ page contentType="text/html;charset=GBK" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ionglobal.db.*" %>
<%@ page import="com.ionglobal.lib.*" %>
<%@ page import="com.ionglobal.misc.*" %>

<%@ include file="../init_include.jsp" %>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<%=Language.getHTMLLanguageStr()%>">
<link rel="stylesheet" href="../css.css" type="text/css">
<script Language="JavaScript" src="../script/Ion_Popup.js"></script> 
<script language="JavaScript1.2">
function isNumber( sValue ){
	return isMakeOf( sValue, "+-.0123456789" );
}
function isPhone( sValue ){
	return isMakeOf( sValue, "+-ext().0123456789" );
}
function isMakeOf( sValue, sElement ){
	var nIndex = 0;
	sValue = sValue.toUpperCase();
	sElement = sElement.toUpperCase();
	
	for (nIndex=0; nIndex<sValue.length; nIndex++)  
    {  
        cCheck = sValue.charAt(nIndex);
        if (sElement.indexOf( cCheck )< 0) {  
			return false;
        }  
    }
	return true;
}

function isEmail( sValue ){
	if ( (sValue.length < 5) &&(sValue.length>0))
		return false;
	else if(sValue.indexOf("@")<=0 )
		return false;
	else if(sValue.indexOf(".")<=0 )
		return false;
	else if( !isMakeOf( sValue, "abcdefghijklmnopqrstuvwxyz0123456789-_.@" ) )
		return false;
	return true;
}
 
 function checkdata(){
 	var sForm = document.formIon;
 	//// checking inputted data in form
	var name = sForm.name.value;
	if( name == "" ){
		alert("<%=Language.getNameByCode("sys.class.alertname","please input name!")%>");
		sForm.name.focus();
		return false;
	}
/*
	var code = sForm.code.value;
	if( code == "" ){
		alert("<%=Language.getNameByCode("sys.class.alertcode","please input code!")%>");
		sForm.code.focus();
		return false;
	}
*/
	sForm.Submit.disabled = true;
  sForm.descript.value=document.editor.getHTML();
 	return true;
 } 
</script>  
<title><%=Language.getNameByCode("sys.class.dj.title","Group Add And Edit:")%></title>
</head>
<%
	int check_rst=Permission.accept(dbi,session,request,"sysop","tree","catid","000000100"); 	
	if (check_rst!=Permission.CHECK_RST_SUCCESS) {
		dbi.closeAll();
		if (check_rst==Permission.CHECK_RST_DENY)
			response.sendRedirect("../deny.html");
		else
			response.sendRedirect("../index.jsp");
		return;		
	}
	
	Sysop sysop=(Sysop)session.getAttribute("sysop");

	
	int classid=0;
	try {	
		if(request.getParameter("id")!=null)
			classid=Integer.parseInt(request.getParameter("id"));		
	} catch (NumberFormatException e) {
		out.println(e);
		return ;
	}
		
	int catid=0;
	try {	
		if(request.getParameter("catid")!=null)
			catid=Integer.parseInt(request.getParameter("catid"));		
	} catch (NumberFormatException e) {
		out.println(e);
		return ;
	}

	String name="",code="",descript="",classcode="";	
	int parentid=0,layer=0;
	if(classid!=0) {
		Classes classes=new Classes(dbi,classid);
		name=classes.getName();
		code=classes.getCode();
		classcode=classes.getClassCode();
		descript=classes.getDescript();
		parentid=classes.getParentid();
		layer=classes.getLayer();
	} else {
		if(request.getParameter("classid")!=null)
			parentid=Integer.parseInt(request.getParameter("classid"));
		if(parentid!=0) {
			Classes classes=new Classes(dbi,parentid);
			layer=classes.getLayer()+1;
			code=classes.getCode();
		} else
			layer=1;
	}
%>

<body>
<%=Language.getNameByCode("sys.CurrentPos","Current Position")%>:<%=Language.getNameByCode("sys.class.dj.title","Group Add And Edit:")%><br> 
<hr>   
<form method="POST" name="formIon" action="sys_class_addmod.jsp" onSubmit="return checkdata();">                
<table border="1" cellpadding="0" cellspacing="0" width="100%">    
	<input type="hidden" name="code_pre" value="<%=code%>">
	<tr><td class="input_title"><%=Language.getNameByCode("sys.class.id","ID")%><font color=red>*</font></td><td><input type="hidden" name="id" size="30" value="<%=classid%>"><%=classid%></td></tr>
	<tr><td class="input_title"><%=Language.getNameByCode("sys.class.name","Name")%> <font color=red>*</font></td><td><input type="text" name="name" size="30" maxlength="80" value="<%=name%>"></td></tr>
	<tr><td class="input_title"><%=Language.getNameByCode("sys.class.code","Code")%> <font color=red>*</font></td><td><input type="text" name="classcode" size="30" maxlength="80" value="<%=classcode%>"></td></tr>
	<tr><td class="input_title"><%=Language.getNameByCode("sys.class.parentid","Parent ID")%><font color=red>*</font></td><td><input type="hidden" name="parentid" size="30" value="<%=parentid%>"><%=parentid%></td></tr>
	<tr><td class="input_title"><%=Language.getNameByCode("sys.class.layer","Layer")%><font color=red>*</font></td><td><input type="hidden" name="layer" size="30" value="<%=layer%>"><%=layer%></td></tr>
	<tr><td class="input_title_text" colspan="2"><%=Language.getNameByCode("sys.class.descript","Descript")%></td></tr>
	<tr><td class="input_editor" colspan="2"><iframe  src="../editor.html" width="100%" height="340" name=editor ></iframe></td></tr> 
</table>      
<input type="Submit" name="Submit" value="<%=Language.getNameByCode("sys.Submit","Submit")%>">
<input type="reset" value="<%=Language.getNameByCode("sys.Reset","Reset")%>" name="Reset">
<input type="button" value="<%=Language.getNameByCode("sys.Close","Close")%>" name="close" onClick="closewindow();">	  
<div name="content_hidden" style="visibility: hidden">
 <textarea name="descript"><%=descript%></textarea>
 </div>
</form>        
 <script>
 var setflag = false;
 function setContent(){
 	if( ! setflag ){
 	if (document.editor.loaded ){
 		document.editor.setHTML(document.formIon.descript.value);
 		setflag=true;
 	}
 	else setTimeout("setContent()",500);
 	}
 }
 setContent();
</script>
</body>                
</html>        
<%@ include file="../init_free.jsp" %>        
